import { Dish } from '@/types/dish'
import { Pagination, PageResult, PageParam } from '@/types/global'
import { http } from '@/utils/http'

type MyParams = Pagination & { subType?: string } // 定义类型 类型是Pagination的属性 + subType属性

export const addOrUpdateApi = (data?: Dish) => {
  return http.post<Dish>('/bk/dish/addOrUpdate', data)
}
export const remove = (id?: number) => {
  return http.post<number>('/bk/dish/remove', { id })
}

export const dishListApi = (param: PageParam) => {
  return http.get<PageResult<Dish>>('/bk/dish/dishList', param)
}

export const dishInfoApi = (id: number) => {
  return http.get<Dish>('/bk/dish/dishInfo', { id })
}

export const dishInfoByNameApi = (param: any) => {
  return http.get<PageResult<Dish>>('/bk/dish/dishInfoByName', param)
}
